/* **********************************************************************************
 *
 * Copyright (c) Ascend.NET Project. All rights reserved.
 *
 * This source code is subject to terms and conditions of the Shared Source License
 * for Ascend. A copy of the license can be found in the License.html file
 * at the root of this distribution. If you can not locate the Shared Source License
 * for Ascend, please send an email to ascend_adm@hotmail.com.
 * By using this source code in any fashion, you are agreeing to be bound by
 * the terms of the Shared Source License for Ascend.NET.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * **********************************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using Ascend.Resources;
using System.ComponentModel.Design;

namespace Ascend.Windows.Forms
{
    /// <summary>
    /// Used to groups collections of controls in a GradientTab.
    /// </summary>
    [DesignTimeVisible(true)]
#if GENERAL_RELEASE
    [Designer(typeof(Ascend.Windows.Forms.Design.GradientTabPageDesigner), typeof(IDesigner))]
#else
    [Designer("Ascend.Windows.Forms.Design.GradientTabPageDesigner, Ascend.Design.v1.5, Culture=neutral, PublicKeyToken=5123e2ac4258b06a", typeof(IDesigner))]
#endif
    [DesignerCategory("Form")]
    [ToolboxItem(false)]
    public class GradientTabPage : ContainerControl
    {
        private GradientTabPageRender _render;
        private Rectangle _tabRectangle = Rectangle.Empty;
        private bool _active;
        private Image _image;
        private bool _tabVisible;
        private int _imageIndex;
        private string _imageKey = string.Empty;
        private ImageList _imageList;
        private string _toolTipText;
        private int _displayOrder;
        private string _key;
        private ContentAlignment _textAlign;
        private ContentAlignment _imageAlign;
        private GradientTabPageTabProperty _gradientTabPageTabProperty;

        /// <summary>
        /// Occurs when the Active property changes. 
        /// </summary>
        [ResourceDescriptionAttribute("ActiveChangedEventDescription"), ResourceCategoryAttribute("PropertyChangedCategory"), ResourceDisplayName("DisplayNameActiveChanged")]
        public event EventHandler ActiveChanged;

        /// <summary>
        /// Occurs when the ImageAlign property changes.
        /// </summary>
        [ResourceDescriptionAttribute("ImageAlignChangedEventDescription"), ResourceCategoryAttribute("PropertyChangedCategory"), ResourceDisplayName("DisplayNameImageAlignChanged")]
        public event EventHandler ImageAlignChanged;

        /// <summary>
        /// Occurs when the ImageIndex property changes. 
        /// </summary>
        [ResourceDescriptionAttribute("ImageIndexChangedEventDescription"), ResourceCategoryAttribute("PropertyChangedCategory"), ResourceDisplayName("DisplayNameImageIndexChanged")]
        public event EventHandler ImageIndexChanged;

        /// <summary>
        /// Occurs when the TextAlign property changes on the navigation button.
        /// </summary>
        [ResourceDescriptionAttribute("TextAlignChangedEventDescription"), ResourceCategoryAttribute("PropertyChangedCategory"), ResourceDisplayName("DisplayNameTextAlignChanged")]
        public event EventHandler TextAlignChanged;


        /// <summary>
        /// Occurs when the ActiveGradientLowColor property changes. 
        /// </summary>
        [ResourceDescriptionAttribute("ActiveGradientLowColorEventDescription"), ResourceCategoryAttribute("PropertyChangedCategory"), ResourceDisplayName("DisplayNameActiveGradientLowColorChanged")]
        public event EventHandler ActiveGradientLowColorChanged;

        /// <summary>
        /// Gets or sets the text associated with this control's tab. 
        /// </summary>
        /// <value>
        /// The text associated with this control's text. 
        /// </value>
        [Browsable(false)]
        public override string Text
        {
            get
            {
                return base.Text;

            }

            set
            {
                base.Text = value;

                if (this.Parent != null)
                {
                    this.Parent.Invalidate();
                    this.Parent.Update();

                }

            }

        }

        /// <summary>
        /// The ContentAlignment associated with this controls tab text.
        /// </summary>
        /// <value>
        /// <para>
        /// System.Drawing.ContentAlignment . The ContentAlignment associated with this controls text.
        /// </para>
        /// <para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [Browsable(false)]
        public ContentAlignment TextAlign
        {
            get
            {
                return this._textAlign;

            }

            set
            {
                if (value == this._textAlign)
                {
                    return;

                }

                this._textAlign = value;

                if (this.Parent != null)
                {
                    this.Parent.Invalidate();

                }

                this.OnTextAlignChanged(new EventArgs());

            }

        }

        private bool IsTextAlignCustomized()
        {
            if (this.Parent != null)
            {
                GradientTab gradientTab = this.Parent as GradientTab;

                if (gradientTab != null)
                {
                    if (gradientTab.TabTextAlign == this._textAlign)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Determines if the TextAlign property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>always true</returns>
        public bool ShouldSerializeTextAlign()
        {
            return true;

        }

        /// <summary>
        /// Gets or sets the tab rectangle
        /// </summary>
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Rectangle TabRectangle
        {
            get
            {
                return this._tabRectangle;

            }

            set
            {
                this._tabRectangle = value;

            }

        }

        /// <summary>
        /// Specifies if the control is currently active (has focus or is selected).
        /// </summary>
        /// <value>
        /// 	<para>
        /// System.Boolean . Specifies if the control is currently active (has focus or is selected).
        /// </para>
        /// 	<para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public virtual bool Active
        {
            get
            {
                return this._active;

            }

            set
            {
                if (value == this._active)
                {
                    return;

                }

                this._active = value;

                this.OnActiveChanged(new EventArgs());

            }

        }

        /// <summary>
        /// The image associated with this control's tab.
        /// </summary>
        /// <value>
        /// 	<para>
        /// System.Drawing.Image . The image associated with this control's tab.
        /// </para>
        /// 	<para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [Browsable(false)]
        public Image Image
        {
            get
            {
                if ((this._image == null) && (this._imageList != null))
                {
                    if (this._imageIndex != -1)
                    {
                        int imageIndex = this._imageIndex;
                        if (imageIndex >= this._imageList.Images.Count)
                        {
                            imageIndex = this._imageList.Images.Count - 1;

                        }

                        if (imageIndex >= 0)
                        {
                            return this._imageList.Images[imageIndex];

                        }

                    }
                    else
                    {
                        if ((this._imageKey != null) && (this._imageKey.Length > 0))
                        {
                            string imageKey = this._imageKey;

                            if (!this._imageList.Images.ContainsKey(imageKey))
                            {
                                int imageIndex = this._imageList.Images.Count - 1;

                                if (imageIndex >= 0)
                                {
                                    return this._imageList.Images[imageIndex];

                                }

                            }
                            else
                            {
                                return this._imageList.Images[imageKey];

                            }

                        }

                    }

                }

                return this._image;

            }

            set
            {
                if (this._image != value)
                {
                    this._image = value;

                    if (this._image != null)
                    {
                        this._imageIndex = -1;
                        this._imageKey = string.Empty;
                        this._imageList = null;

                    }

                    if (this.Parent != null)
                    {
                        this.Parent.Invalidate();
                        this.Parent.Update();

                    }

                }

            }

        }

        /// <summary>
        /// The ContentAlignment associated with this controls image.
        /// </summary>
        /// <value>
        /// <para>
        /// System.Drawing.ContentAlignment . The ContentAlignment associated with this controls image.
        /// </para>
        /// <para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [Browsable(false)]
        public ContentAlignment ImageAlign
        {
            get
            {
                return this._imageAlign;

            }

            set
            {
                if (value == this._imageAlign)
                {
                    return;

                }

                this._imageAlign = value;

                if (this.Parent != null)
                {
                    this.Parent.Invalidate();

                }

                this.OnImageAlignChanged(new EventArgs());

            }

        }

        private bool IsImageAlignCustomized()
        {
            if (this.Parent != null)
            {
                GradientTab gradientTab = this.Parent as GradientTab;

                if (gradientTab != null)
                {
                    if (gradientTab.TabImageAlign == this._imageAlign)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Determines if the ImageAlign property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>always true</returns>
        public bool ShouldSerializeImageAlign()
        {
            return true;

        }

        /// <summary>
        /// Gets or sets a value indicating whether the page tab is displayed. 
        /// </summary>
        /// <value>
        /// true if the tab is displayed; otherwise, false. The default is true.
        /// </value>
        [ResourceDescriptionAttribute("TabVisibleDescription"), ResourceCategoryAttribute("BehaviorCategory"), ResourceDisplayName("DisplayNameTabVisible"), DefaultValueAttribute(true), RefreshProperties(RefreshProperties.Repaint)]
        public bool TabVisible
        {
            get
            {
                return this._tabVisible;

            }

            set
            {
                this._tabVisible = value;

            }

        }

        /// <summary>
        /// Gets or set the tab active gradient high color.
        /// </summary>
        [Browsable(false)]
        public Color ActiveGradientHighColor
        {
            get
            {
                return this._render.TabActiveGradientHighColor;

            }

            set
            {
                if (this._render.TabActiveGradientHighColor == value)
                {
                    return;

                }

                this._render.TabActiveGradientHighColor = value;

                base.Invalidate();

                if (this.Parent != null)
                {
                    this.Parent.Invalidate();

                }

            }

        }

        /// <summary>
        /// Determines if the ActiveGradientHighColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>always true</returns>
        public bool ShouldSerializeActiveGradientHighColor()
        {
            return true;

        }

        private bool IsActiveGradientHighColorCustomized()
        {
            if (this.Parent != null)
            {
                GradientTab gradientTab = this.Parent as GradientTab;

                if (gradientTab != null)
                {
                    if (gradientTab.TabActiveGradientHighColor == this.ActiveGradientHighColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or set tab active gradient low color.
        /// </summary>
        [Browsable(false)]
        public Color ActiveGradientLowColor
        {
            get
            {
                
                return this._render.TabActiveGradientLowColor;

            }

            set
            {
                if (this._render.TabActiveGradientLowColor == value)
                {
                    return;

                }

                this._render.TabActiveGradientLowColor = value;

                base.Invalidate();

                if (this.Parent != null)
                {
                    this.Parent.Invalidate();

                }

            }

        }

        /// <summary>
        /// Determines if the ActiveGradientLowColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>always true</returns>
        public bool ShouldSerializeActiveGradientLowColor()
        {
            return true;

        }

        private bool IsActiveGradientLowColorCustomized()
        {
            if (this.Parent != null)
            {
                GradientTab gradientTab = this.Parent as GradientTab;

                if (gradientTab != null)
                {
                    if (gradientTab.TabActiveGradientLowColor == this.ActiveGradientLowColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the gradient high (lighter) color for the tab when it is moused over.
        /// </summary>
        [Browsable(false)]
        public Color HighlightGradientHighColor
        {
            get
            {
                return this._render.TabHighlightGradientHighColor;

            }

            set
            {
                if (this._render.TabHighlightGradientHighColor == value)
                {
                    return;

                }

                this._render.TabHighlightGradientHighColor = value;

                base.Invalidate();

                if (this.Parent != null)
                {
                    this.Parent.Invalidate();

                }

            }

        }
        
        /// <summary>
        /// Determines if the HighlightGradientHighColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>always true</returns>
        public bool ShouldSerializeHighlightGradientHighColor()
        {
            return true;

        }

        private bool IsHighlightGradientHighColorCustomized()
        {
            if (this.Parent != null)
            {
                NavigationPane parentNavigationPane = this.Parent as NavigationPane;

                if (parentNavigationPane != null)
                {
                    if (parentNavigationPane.ButtonHighlightGradientHighColor == this.HighlightGradientHighColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the gradient low (darker) color for the button when it is moused over.
        /// </summary>
        [Browsable(false)]
        public Color HighlightGradientLowColor
        {
            get
            {
                return this._render.TabHighlightGradientLowColor;

            }

            set
            {
                if (this._render.TabHighlightGradientLowColor == value)
                {
                    return;

                }

                this._render.TabHighlightGradientLowColor = value;

                base.Invalidate();

                if (this.Parent != null)
                {
                    this.Parent.Invalidate();

                }

            }

        }

        /// <summary>
        /// Determines if the HighlightGradientLowColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>always true</returns>
        public bool ShouldSerializeHighlightGradientLowColor()
        {
            return true;

        }

        private bool IsHighlightGradientLowColorCustomized()
        {
            if (this.Parent != null)
            {
                NavigationPane parentNavigationPane = this.Parent as NavigationPane;

                if (parentNavigationPane != null)
                {
                    if (parentNavigationPane.ButtonHighlightGradientLowColor == this.HighlightGradientLowColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the button gradient high color on the control.
        /// </summary>
        [Browsable(false)]
        public Color GradientHighColor
        {
            get
            {
                return this._render.TabGradientHighColor;

            }

            set
            {
                if (this._render.TabGradientHighColor == value)
                {
                    return;

                }

                this._render.TabGradientHighColor = value;

                base.Invalidate();

                if (this.Parent != null)
                {
                    this.Parent.Invalidate();

                }

            }

        }

        /// <summary>
        /// Determines if the GradientHighColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>always true</returns>
        public bool ShouldSerializeGradientHighColor()
        {
            return true;

        }

        private bool IsTabGradientHighColorCustomized()
        {
            if (this.Parent != null)
            {
                NavigationPane parentNavigationPane = this.Parent as NavigationPane;

                if (parentNavigationPane != null)
                {
                    if (parentNavigationPane.ButtonGradientHighColor == this.GradientHighColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the button gradient low color.
        /// </summary>
        [Browsable(false)]
        public Color GradientLowColor
        {
            get
            {
                return this._render.TabGradientLowColor;

            }

            set
            {
                if (this._render.TabGradientLowColor == value)
                {
                    return;

                }

                this._render.TabGradientLowColor = value;

                base.Invalidate();

                if (this.Parent != null)
                {
                    this.Parent.Invalidate();

                }

            }

        }

        /// <summary>
        /// Determines if the GradientLowColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>always true</returns>
        public bool ShouldSerializeGradientLowColor()
        {
            return true;

        }

        private bool IsTabGradientLowColorCustomized()
        {
            if (this.Parent != null)
            {
                NavigationPane parentNavigationPane = this.Parent as NavigationPane;

                if (parentNavigationPane != null)
                {
                    if (parentNavigationPane.ButtonGradientLowColor == this.GradientLowColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the font associated with the tabs.
        /// </summary>
        [Browsable(false)]
        public Font TabFont
        {
            get
            {
                return this._render.TabFont;

            }

            set
            {
                if (this._render.TabFont == value)
                {
                    return;

                }

                this._render.TabFont = value;

                base.Invalidate();

                if (this.Parent != null)
                {
                    this.Parent.Invalidate();

                }

            }

        }

        /// <summary>
        /// Gets or sets the forecolor associated with the tabs.
        /// </summary>
        [Browsable(false)]
        public Color TabForeColor
        {
            get
            {
                return this._render.TabForeColor;

            }

            set
            {
                if (this._render.TabForeColor == value)
                {
                    return;

                }

                this._render.TabForeColor = value;

                base.Invalidate();

                if (this.Parent != null)
                {
                    this.Parent.Invalidate();

                }

            }

        }

        private bool IsTabForeColorCustomized()
        {
            if (this.Parent != null)
            {
                NavigationPane parentNavigationPane = this.Parent as NavigationPane;

                if (parentNavigationPane != null)
                {
                    if (parentNavigationPane.ButtonForeColor == this.TabForeColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Determines if the ButtonForeColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>always true</returns>
        public bool ShouldSerializeButtonForeColor()
        {
            return true;

        }

        /// <summary>
        /// Gets or sets the image list index value of the image displayed on the control's button. 
        /// </summary>
        [Browsable(false)]
        public int ImageIndex
        {
            get
            {
                if (((this._imageIndex != -1) && (this._imageList != null)) && (this._imageIndex >= this._imageList.Images.Count))
                {
                    return (this._imageList.Images.Count - 1);

                }

                return this._imageIndex;

            }

            set
            {
                if (this._imageIndex != value)
                {
                    if (value != -1)
                    {
                        this._image = null;
                        this._imageKey = string.Empty;

                    }

                    this._imageIndex = value;

                    if (this.Parent != null)
                    {
                        this.Parent.Invalidate();
                        this.Parent.Update();

                    }

                    this.OnImageIndexChanged(new EventArgs());

                }

            }

        }

        /// <summary>
        /// Gets or sets the key associated with the page.
        /// </summary>
        [ResourceDescriptionAttribute("KeyDescription"), ResourceCategoryAttribute("BehaviorCategory"), ResourceDisplayName("DisplayNameKey")]
        public string Key
        {
            get
            {
                return this._key;

            }

            set
            {
                if (this._key != value)
                {
                    if (value != null)
                    {
                        this._key = value;

                    }

                }

            }

        }

        /// <summary>
        /// Gets or sets the space between controls.
        /// </summary>
        /// <value>
        /// A Padding representing the space between controls.
        /// </value>
        /// <remarks>
        /// The margin of this control is managed by the parent NavigationPane.
        /// </remarks>
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Padding Margin
        {
            get
            {
                return base.Margin;

            }

            set
            {
                base.Margin = value;

            }

        }

        /// <summary>
        /// Gets or sets the minimum size the form can be resized to. 
        /// </summary>
        /// <value>
        /// A Size that represents the minimum size for the form. 
        /// </value>
        /// <remarks>
        /// The size of this control is controled by the parent NavigationPane.
        /// </remarks>
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override System.Drawing.Size MinimumSize
        {
            get
            {
                return base.MinimumSize;

            }

            set
            {
                base.MinimumSize = value;

            }

        }

        /// <summary>
        /// Gets or sets the height and width of the control.
        /// </summary>
        /// <value>
        /// The Size that represents the height and width of the control in pixels.
        /// </value>
        /// <remarks>
        /// The size of this control is controled by the parent NavigationPane.
        /// </remarks>
        [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
        public new Size Size
        {
            get
            {
                return base.Size;

            }

            set
            {
                base.Size = value;

            }

        }

        /// <summary>
        /// Gets or sets the key for the image that is displayed for the button.
        /// </summary>
        [Browsable(false)]
        public string ImageKey
        {
            get
            {
                if (((!String.IsNullOrEmpty(this._imageKey)) && (this._imageList != null)) && (!this._imageList.Images.ContainsKey(this._imageKey)))
                {
                    return this._imageList.Images.Keys[(this._imageList.Images.Count - 1)];

                }

                return this._imageKey;

            }

            set
            {
                if (this._imageKey != value)
                {
                    if (value != null)
                    {
                        this._image = null;
                        this._imageIndex = -1;

                    }

                    if (value == "(none)")
                    {
                        this._image = null;
                        this._imageIndex = -1;
                        this._imageKey = string.Empty;

                    }
                    else
                    {
                        this._imageKey = value;

                    }

                    if (this.Parent != null)
                    {
                        this.Parent.Invalidate();
                        this.Parent.Update();

                    }

                }

            }

        }

        /// <summary>
        /// Gets or sets the ImageList that contains the Image displayed on the control. 
        /// </summary>
        [Browsable(false)]
        public ImageList ImageList
        {
            get
            {
                return this._imageList;

            }

            set
            {
                if (this._imageList != value)
                {
                    if (value != null)
                    {
                        this._image = null;

                    }

                    this._imageList = value;

                    if (this.Parent != null)
                    {
                        this.Parent.Invalidate();
                        this.Parent.Update();

                    }

                }


            }

        }

        /// <summary>
        /// 
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
        public new Point Location
        {
            get
            {
                return base.Location;

            }

            set
            {
                base.Location = value;

            }

        }

        /// <summary>
        /// Determines if the Location property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeLocation()
        {
            if (base.Left == 0)
            {
                return (base.Top != 0);

            }
            
            return true;

        }

        /// <summary>
        /// The tooltip text to display when the button is minimized.
        /// </summary>
        [Browsable(false)]
        public string ToolTipText
        {
            get
            {
                return this._toolTipText;

            }

            set
            {
                this._toolTipText = value;

            }

        }

        /// <summary>
        /// Sets or returns the specified background color for the style. The default value is Window. 
        /// </summary>
        [ResourceDescriptionAttribute("BackColorDescription"), ResourceCategoryAttribute("AppearanceCategory"), ResourceDisplayName("DisplayNameBackColor"), DefaultValueAttribute(typeof(Color), "Window")]
        public override System.Drawing.Color BackColor
        {
            get
            {
                return base.BackColor;

            }

            set
            {
                base.BackColor = value;

            }

        }

        /// <summary>
        /// Sets or returns the specified foreground color for the style. Typically, this property sets the color for the text. The default value is WindowText. 
        /// </summary>
        [ResourceDescriptionAttribute("ForeColorDescription"), ResourceCategoryAttribute("AppearanceCategory"), ResourceDisplayName("DisplayNameForeColor"), DefaultValueAttribute(typeof(Color), "WindowText")]
        public override System.Drawing.Color ForeColor
        {
            get
            {
                return base.ForeColor;

            }

            set
            {
                base.ForeColor = value;

            }

        }
        /// <summary>
        /// Gets or sets the display (render) order of the tab.
        /// </summary>
        [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public int TabDisplayOrder
        {
            get
            {
                return this._displayOrder;

            }

            set
            {
                this._displayOrder = value;

            }

        }

        /// <summary>
        /// Gets or sets the tab properties.
        /// </summary>
        ///         
        [DesignOnlyAttribute(true), EditorBrowsableAttribute(EditorBrowsableState.Never), ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("TabDescription"), ResourceDisplayName("DisplayNameTab")]
        public GradientTabPageTabProperty Tab
        {
            get
            {
                return this._gradientTabPageTabProperty;

            }

            set
            {
                this._gradientTabPageTabProperty = value;

            }

        }

        /// <summary>
        /// Determines if the Tab property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeTab()
        {
            if (this.IsTextAlignCustomized() || this.IsImageAlignCustomized() || this.IsTabForeColorCustomized() || this.IsTabGradientHighColorCustomized() || this.IsTabGradientLowColorCustomized() || this.IsActiveGradientHighColorCustomized() || this.IsActiveGradientLowColorCustomized() || this.IsHighlightGradientHighColorCustomized() || this.IsHighlightGradientLowColorCustomized())
            {
                return true;

            }
            else
            {
                return false;

            }

        }

        /// <summary>
        /// Resets the tab to default values.
        /// </summary>
        public void ResetTab()
        {
            if (this.Parent != null)
            {
                GradientTab gradientTab = this.Parent as GradientTab;

                if (gradientTab != null)
                {
                    this.ActiveGradientHighColor = gradientTab.TabActiveGradientHighColor;
                    this.ActiveGradientLowColor = gradientTab.TabActiveGradientLowColor;
                    this.TabForeColor = gradientTab.TabForeColor;
                    this.GradientHighColor = gradientTab.TabGradientHighColor;
                    this.GradientLowColor = gradientTab.TabGradientLowColor;
                    this.HighlightGradientHighColor = gradientTab.TabHighlightGradientHighColor;
                    this.HighlightGradientLowColor = gradientTab.TabHighlightGradientLowColor;
                    this.Image = null;
                    this.ImageAlign = gradientTab.TabImageAlign;
                    this.ImageIndex = -1;
                    this.ImageKey = string.Empty;
                    this.TextAlign = gradientTab.TabTextAlign;
                    this.ToolTipText = string.Empty;

                }

            }

        }

        /// <summary>
        /// Initializes a new instance of the NavigationPanePage clas.
        /// </summary>
        public GradientTabPage()
        {
            this.BackColor = SystemColors.Window;
            this.ForeColor = SystemColors.WindowText;
            this._tabVisible = true;
            this._imageIndex = -1;
            this.AutoScroll = true;
            this._textAlign = ContentAlignment.MiddleLeft;
            this._imageAlign = ContentAlignment.MiddleLeft;
            this._render = new GradientTabPageRender(this);
            this._gradientTabPageTabProperty = new GradientTabPageTabProperty(this);
            
        }

        /// <summary>
        /// Fires the event indicating that control active property has changed.  Inheriting controls should use this in favour of actually listening to the event, but should not forget to call base.OnActiveChanged() to ensure that the event is still fired for external listeners.
        /// </summary>
        /// <param name="e">A System.EventArgs that contains the event data.</param>
        protected void OnActiveChanged(EventArgs e)
        {
            if (this.ActiveChanged != null)
            {
                this.ActiveChanged(this, e);

            }

        }

        /// <summary>
        /// Fires the event indicating that control image alignment has changed.  Inheriting controls should use this in favour of actually listening to the event, but should not forget to call base.OnImageAlignChanged() to ensure that the event is still fired for external listeners.
        /// </summary>
        /// <param name="e">A System.EventArgs that contains the event data.</param>
        protected virtual void OnImageAlignChanged(EventArgs e)
        {
            if (this.ImageAlignChanged != null)
            {
                this.ImageAlignChanged(this, e);

            }

        }

        private void OnImageIndexChanged(EventArgs e)
        {
            if (this.ImageIndexChanged != null)
            {
                this.ImageIndexChanged(this, e);

            }

        }

        /// <summary>
        /// Fires the event indicating that control text alignment has changed.  Inheriting controls should use this in favour of actually listening to the event, but should not forget to call base.OnTextAlignChanged() to ensure that the event is still fired for external listeners.
        /// </summary>
        /// <param name="e">A System.EventArgs that contains the event data.</param>
        protected virtual void OnTextAlignChanged(EventArgs e)
        {
            if (this.TextAlignChanged != null)
            {
                this.TextAlignChanged(this, e);

            }

        }


        /// <summary>
        /// Fires the event indicating that control ActiveGradientLowColor property has changed.  Inheriting controls should use this in favour of actually listening to the event, but should not forget to call base.OnActiveGradientLowColorChanged() to ensure that the event is still fired for external listeners.
        /// </summary>
        /// <param name="e">A System.EventArgs that contains the event data.</param>
        protected void OnActiveGradientLowColorChanged(EventArgs e)
        {
            if (this.ActiveGradientLowColorChanged != null)
            {
                this.ActiveGradientLowColorChanged(this, e);

            }

        }

    }

}
